const { createHash } = require("crypto");
const {
  appFuncID,
  rnPackageID,
  packageAuditID,
  opLogID,
  userMgntID,
  auditID,
  userSettingID,
  userRoleMgmtID,
  profileFuncID,
  developerRoleID,
  masterRoleID,
  adminRoleID,
  orgFuncID,
  orgUserFuncID,
  rootID
} = require("../generator");

module.exports = {
  up: (queryInterface, Sequelize) => {
    return queryInterface.bulkInsert(
      "t_role_func",
      [
        {
          id: `${Math.random() * Date.now()}`,
          role_id: developerRoleID,
          func_id: appFuncID,
          create_user_id: rootID,
          modify_user_id: rootID,
          create_time: new Date(),
          modify_time: new Date()
        },
        {
          id: `${Math.random() * Date.now()}`,
          role_id: masterRoleID,
          func_id: appFuncID,
          create_user_id: rootID,
          modify_user_id: rootID,
          create_time: new Date(),
          modify_time: new Date()
        },
        {
          id: `${Math.random() * Date.now()}`,
          role_id: adminRoleID,
          func_id: appFuncID,
          create_user_id: rootID,
          modify_user_id: rootID,
          create_time: new Date(),
          modify_time: new Date()
        },
        {
          id: `${Math.random() * Date.now()}`,
          role_id: developerRoleID,
          func_id: profileFuncID,
          create_user_id: rootID,
          modify_user_id: rootID,
          create_time: new Date(),
          modify_time: new Date()
        },
        {
          id: `${Math.random() * Date.now()}`,
          role_id: masterRoleID,
          func_id: profileFuncID,
          create_user_id: rootID,
          modify_user_id: rootID,
          create_time: new Date(),
          modify_time: new Date()
        },
        {
          id: `${Math.random() * Date.now()}`,
          role_id: adminRoleID,
          func_id: profileFuncID,
          create_user_id: rootID,
          modify_user_id: rootID,
          create_time: new Date(),
          modify_time: new Date()
        },
        {
          id: `${Math.random() * Date.now()}`,
          role_id: developerRoleID,
          func_id: orgFuncID,
          create_user_id: rootID,
          modify_user_id: rootID,
          create_time: new Date(),
          modify_time: new Date()
        },
        {
          id: `${Math.random() * Date.now()}`,
          role_id: masterRoleID,
          func_id: orgFuncID,
          create_user_id: rootID,
          modify_user_id: rootID,
          create_time: new Date(),
          modify_time: new Date()
        },
        {
          id: `${Math.random() * Date.now()}`,
          role_id: adminRoleID,
          func_id: orgFuncID,
          create_user_id: rootID,
          modify_user_id: rootID,
          create_time: new Date(),
          modify_time: new Date()
        },
        {
          id: `${Math.random() * Date.now()}`,
          role_id: adminRoleID,
          func_id: rnPackageID,
          create_user_id: rootID,
          modify_user_id: rootID,
          create_time: new Date(),
          modify_time: new Date()
        },
        {
          id: `${Math.random() * Date.now()}`,
          role_id: adminRoleID,
          func_id: packageAuditID,
          create_user_id: rootID,
          modify_user_id: rootID,
          create_time: new Date(),
          modify_time: new Date()
        },
        {
          id: `${Math.random() * Date.now()}`,
          role_id: adminRoleID,
          func_id: opLogID,
          create_user_id: rootID,
          modify_user_id: rootID,
          create_time: new Date(),
          modify_time: new Date()
        },
        {
          id: `${Math.random() * Date.now()}`,
          role_id: adminRoleID,
          func_id: userSettingID,
          create_user_id: rootID,
          modify_user_id: rootID,
          create_time: new Date(),
          modify_time: new Date()
        },
        {
          id: `${Math.random() * Date.now()}`,
          role_id: adminRoleID,
          func_id: userRoleMgmtID,
          create_user_id: rootID,
          modify_user_id: rootID,
          create_time: new Date(),
          modify_time: new Date()
        },
        {
          id: `${Math.random() * Date.now()}`,
          role_id: adminRoleID,
          func_id: userMgntID,
          create_user_id: rootID,
          modify_user_id: rootID,
          create_time: new Date(),
          modify_time: new Date()
        },
        {
          id: `${Math.random() * Date.now()}`,
          role_id: adminRoleID,
          func_id: auditID,
          create_user_id: rootID,
          modify_user_id: rootID,
          create_time: new Date(),
          modify_time: new Date()
        }
      ],
      {}
    );
  },

  down: (queryInterface, Sequelize) => {
    return queryInterface.bulkDelete("t_role_func", null, {});
  }
};
